package com.khshop.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.khshop.pojo.Admin;
import com.khshop.mapper.AdminMapper;
import com.khshop.service.AdminService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;

/**
 * <p>
 * 管理员 服务实现类
 * </p>
 *
 * @author zhaoyang
 * @since 2020-10-08
 */
@Service
public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements AdminService {

    @Autowired(required = false)
    private AdminMapper adminMapper;

    @Override
    public Admin getAdmin(String name) {
        QueryWrapper<Admin> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("uname",name);
        return adminMapper.selectOne(queryWrapper);
    }
    @Override
    public boolean addAdmin(Admin admin){
        return adminMapper.insert(admin)>0;
    };

    @Override
    public boolean updateAdmin(Admin admin) {
        return adminMapper.updateById(admin)>0;
    }

    @Override
    public boolean delAdmin(Long id) {
        return adminMapper.deleteById(id)>0;
    }
}
